<?php // (gethostbyname($_SERVER['HTTP_HOST'])!='67.43.157.85')?exit('Invalid Host'):'';?><?php

if (!eregi("modules.php", $_SERVER['SCRIPT_NAME'])) {
    die ("You can't access this file directly...");
}

$module_name = basename(dirname(__FILE__));
require_once("mainfile.php");
require_once("modules/Shop/s_config.php");
require_once("modules/Shop/themes/theme.php");
get_lang($module_name);



$index = $indexhome;

?>
<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function CaricaFoto(img){
  foto1= new Image();
  foto1.src=(img);
  Controlla(img);
}
function Controlla(img){
  if((foto1.width!=0)&&(foto1.height!=0)){
    viewFoto(img);
  }
  else{
    funzione="Controlla('"+img+"')";
    intervallo=setTimeout(funzione,20);
  }
}
function viewFoto(img){
  largh=foto1.width+20;
  altez=foto1.height+20;
  stringa="width="+largh+",height="+altez;
  finestra=window.open(img,"",stringa);
}
//  End -->
</script>

<?

function checkgoods() {
global $prefix, $db, $module_name;
    $hresult = $db->sql_query("SELECT pid, limit_date, action, action_fdate, status FROM ".$prefix."_shop");
    while ($hrow = $db->sql_fetchrow($hresult)) {
    $c_pid = $hrow[pid];
    $c_limit_date = $hrow[limit_date];
    $c_action = $hrow[action];
    $c_action_fdate = $hrow[action_fdate];
    $c_status = $hrow[status];
    $xdate = time();
    if (($c_status==1) && ($c_limit_date > 0) && ($c_limit_date <= $xdate)) {
    $db->sql_query("UPDATE ".$prefix."_shop SET status='0', limit_date='-1', action='0', action_fdate='-1', show_home='0' WHERE pid='$c_pid'");
   } elseif (($c_status==1) && (($c_limit_date == 0) || ($c_limit_date > $xdate)) && ($c_action_fdate != 0) && ($c_action_fdate <= $xdate)) {
   $db->sql_query("UPDATE ".$prefix."_shop SET action='0', action_fdate='-1' WHERE pid='$c_pid'");
   }
   }
}


function docookieclient($urlrefl) {
    global $home, $hle;
  if ($_COOKIE["client"] == "") {
    $datakod = date(U);
    $client = "CL_".$datakod."";
    $client = base64_encode("$client");
    //$client = "";
    $hle2 = $hle * 86400;
    setcookie("client","$client",time() + $hle2);//14 ngay
    if ($urlrefl != "") {
    	if($home == 1) $urlrefl = "index.php";
    } else {
    	$urlfl = $_SERVER['QUERY_STRING'];
    	$urlfl = "modules.php?$urlfl";
    }
    echo "<META HTTP-EQUIV=\"refresh\" content=\"0;URL=$urlrefl\">";
  }
}

function links($sc_cid) {
   global $prefix, $db, $module_name;
   $sc_cid = intval($sc_cid);
   $sql = "SELECT cid  FROM ".$prefix."_shop_categories WHERE parentid = '$sc_cid'";
   $resnum = $db->sql_query($sql);
   if ($numrows = $db->sql_numrows($resnum) > 0) {
   $cat_links = "cat"; }
   else {
   $cat_links = "showcat"; }
   echo "<a style=\"TEXT-DECORATION: none\" href=\"modules.php?name=$module_name&go=$cat_links&cid=$sc_cid\">";
}

function getparent($parentid, $title, $pid) {
    global $prefix, $db, $module_name;
    $res = $db->sql_query("select cid, cat_title, parentid from ".$prefix."_shop_categories where cid='$parentid'");
    $row = $db->sql_fetchrow($res);
    $cid = $row[cid];
    $ptitle = $row[cat_title];
    $pparentid = $row[parentid];
    if (($ptitle!="") AND ($pid == "")) {
    $title="<a style=\"TEXT-DECORATION: none\" href=\"modules.php?name=$module_name&go=cat&cid=$cid\">".$ptitle."</a> - ".$title."";
    }
    else if (($ptitle!="") AND ($pid != "")) {
    $result3 = $db->sql_query("SELECT cid FROM ".$prefix."_shop WHERE pid='$pid'");
    $row3 = $db->sql_fetchrow($result);
    $p_cid = $row3[cid];
    
    $res2 = $db->sql_query("select cid from ".$prefix."_shop_categories where cid='$p_cid'");
    $row2 = $db->sql_fetchrow($res2);
    $title="<a style=\"TEXT-DECORATION: none\" href=\"modules.php?name=$module_name&go=cat&cid=$cid\">".$ptitle."</a> - <a style=\"TEXT-DECORATION: none\" href=\"modules.php?name=$module_name&go=showcat&cid=$row2[cid]\">".$title."</a>";
    }
    if ($pparentid!=0) {
    $title=getparent($pparentid, $title, $pid);
    }
    return $title;
}

function getparent2($parentid,$title) {
    global $prefix,$db;
    $sql = "select cid, cat_title, parentid from ".$prefix."_shop_categories where cid='$parentid'";
    $result = $db->sql_query($sql);
    $row = $db->sql_fetchrow($result);
    $cid = $row[cid];
    $ptitle = $row[cat_title];
    $pparentid = $row[parentid];
    if ($ptitle!="") $title=$ptitle." | ".$title;
    if ($pparentid!=0) {
        $title=getparent($pparentid,$title);
    }
    return $title;
}

function menu($c_cid, $pid) {
  global $ThemeSel, $prefix, $db, $module_name, $module_title, $cur, $user, $cookie;
    echo "<table border=\"0\" cellpadding=\"1\" cellspacing=\"10\" width=\"100%\"><tr>";
    cookiedecode($user);
    getusrinfo($user);
    if (($userinfo[username] != $cookie[1]) AND ($userinfo[user_password] != $cookie[2])) {
    echo "<td width=\"24\"><a href=\"modules.php?name=$module_name&go=order_history\"><img border=\"0\" src=\"modules/Shop/themes/images/money.gif\" width=\"24\" height=\"24\" alt=\""._ORDERHIS."\"></a></td>";
    }
    echo "<td><a href=modules.php?name=$module_name>$module_title</a>  - ";
    if ($c_cid == "basket")  { echo "<a href=modules.php?name=$module_name&go=order_history>"._ORDERHIS."</a> - <a href=modules.php?name=$module_name&go=basket>"._YOURBASKET."</a>"; }
    elseif ($c_cid == "search")  { echo "<a href=modules.php?name=$module_name&go=search>"._SEARCH."</a>"; }
    elseif ($c_cid == "action")  { echo "<a href=modules.php?name=$module_name&go=action>"._SHOPACTION."</a>"; }
    else {
    $mresult = $db->sql_query("SELECT cid, cat_title, parentid FROM ".$prefix."_shop_categories WHERE cid='$c_cid'");
    $row = $db->sql_fetchrow($mresult);
    $cc_cid = $row[cid];
    $c_title = $row[cat_title];
    $c_parentisd = $row[parentid];
    echo "".getparent($c_parentisd, $c_title, $pid)."";
    }
    echo "<hr style=\"border-style: dotted; border-width: 1px\"></td>";
    $client = $_COOKIE["client"];
    $client = base64_decode($client);
    if ($client != "") {
    $total_sum = 0;
    $total_count = 0;
    $fresult = $db->sql_query("SELECT g_price, g_count FROM ".$prefix."_shop_usercat WHERE g_uname='$client'");
    while ($row = $db->sql_fetchrow($fresult)) {
    $sum = $row[g_price]*$row[g_count];
    $total_sum = $total_sum+$sum;
    $total_count = $total_count+$row[g_count];
    }
    $total_sum = number_format($total_sum, 0, '.', ' ');
    $alttt = ""._YOURBASKET.":\n"._ORGOODSCOUNT." $total_count\n"._TOTSUM." $total_sum $cur";
    echo "<td width=\"24\"><a href=\"modules.php?name=Shop&go=basket\"><img border=\"0\" src=\"modules/Shop/themes/images/card.gif\" width=\"24\" height=\"24\" alt=\"$alttt\"></a></td>";
    }
    echo "</tr></table>";
}

function footmenu() {
    global $module_name, $prefix, $db, $user, $admin, $ThemeSel;
    $catresult = $db->sql_query("SELECT cid, cat_title, view, groups, parentid FROM ".$prefix."_shop_categories ORDER BY parentid, weight, cat_title");
    OpenTable();
    echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n";
    echo "<tr>\n";
    echo "<td>\n";
    echo"<script language=\"JavaScript\">\n"
    . "<!-- Hide the script from old browsers --\n"
    . "function JumpToo(form) { \n"
    . "var myindex=form.catid.selectedIndex;\n"
    . "if (form.catid.options[myindex].value != \"0\") {\n"
    . "parent.location=form.catid.options[myindex].value; \n"
    . "}\n"
    . "}\n"
    . "//--> \n"
    . "</script>\n";
    echo"<form method=\"post\">\n"
     . "<select name=\"catid\" onChange=\"JumpToo(this.form)\"><option value=\"0\">"._EXPRESSCAT."</option>\n";
     echo "<option value=\"modules.php?name=$module_name\">"._PAGEHOME."</option>\n";
    while ($row = $db->sql_fetchrow($catresult)) {
        $cidcat = $row[cid];
        $titlecat = $row[cat_title];
        $parentidcat = $row[parentid];
        $view = $row[view];
        $groups = $row[groups];
        if ((($admin)) || ($view > 3 AND in_groups($groups)) || ($view == 3 AND !is_user($user)) || ($view == 1 AND is_user($user)) || ($view == 0)) {
            if ($parentidcat!=0) { $titlecat=getparent2($parentidcat,$titlecat); }
            if ($db->sql_numrows($db->sql_query("select * from ".$prefix."_shop_categories where parentid='$cidcat'")) != 0) {
            echo "<option value=\"modules.php?name=$module_name&go=cat&cid=$cidcat\">$titlecat</option>\n";
            } else {
            echo "<option value=\"modules.php?name=$module_name&go=showcat&cid=$cidcat\">$titlecat</option>\n";
            }
        }
    }
    echo "<option value=\"modules.php?name=$module_name&go=action\">"._SHOPACTION."</option>\n";
    echo "</select></form>";
    echo "</td>";
    echo "<form action=\"modules.php?name=$module_name\" method=\"post\">"
    . "<td align=\"right\">"
    . "<input type=\"text\" name=\"query\" size=\"23\" maxLength=\"57\" onblur=\"if (this.value==''){this.value='"._SEARCH."';}\" onfocus=\"if (this.value=='"._SEARCH."') {this.value = '';}\" value=\""._SEARCH."\" style=\"text-align: center\">"
    . "</td>"
    . "<td width=\"24\">"
    ."<input type=\"hidden\" name=\"go\" value=\"search\">"
    ."<input type=\"submit\" value=\"Go!\">"
    . "</td>"
    . "</form>";
    echo "</tr></table>\n";
    CloseTable();
}

function search($query) {
global $db, $prefix, $module_name, $admin, $user;
     $checkurl = $_SERVER['REQUEST_URI'];
     if (preg_match("/http:\/\//i", $checkurl)) {
     Header("Location: index.php");
     exit;
     }
    checkgoods();
    include("header.php");
    docookieclient($urlrefl);
    $xcid = "search";
    menu($xcid, $pid);
  $query = stripslashes(check_html($query, nohtml));
  if (($query != "") AND ($query != ""._SEARCH."")) {
    OpenTable();
     $dresult = $db->sql_query("select pid, cid, title, addition, firm description from ".$prefix."_shop where (title like '%$query%' OR addition like '%$query%' OR description like '%$query%' OR firm like '%$query%') AND status = '1'");
     $nrows  = $db->sql_numrows($dresult);
     if ($nrows>0) {
     $ddd = "";
     while ($row = $db->sql_fetchrow($dresult)) {
     $pid = $row[pid];
     $cid = $row[cid];
     list($xview, $xgroups) = $db->sql_fetchrow($db->sql_query("SELECT view, groups FROM ".$prefix."_shop_categories WHERE cid='$cid'"));
     if ((($admin)) || ($xview > 3 AND in_groups($xgroups)) || ($xview == 3 AND !is_user($user)) || ($xview == 1 AND is_user($user)) || ($xview == 0)) {
     $title = $row[title];
     $addition = $row[addition];
     $description = $row[description];
     $text = "$addition<br>$description";
     $text = stripslashes(check_html($text, nohtml));
     $text = substr($text, 0, 150);
     $furl = "modules.php?name=$module_name&go=goods&pid=$pid";
     $ddd .= "<a href=\"$furl\"><b>$title</b></a></font><br><i>$text ...</i><br><br>";
     }
     }
     }
     if (($nrows > 0) && ($ddd!="")) {
     echo "$ddd";
    } else {
     echo "<center><font size=\"2\"><b>"._NOMATCHES."</b></font></center>";
     }
   CloseTable();
  }
footmenu();
include("footer.php");
}

function main() {
    global $xdate, $ThemeSel, $db, $prefix, $module_name, $multilingual, $currentlang, $cur, $user, $admin, $homnum, $hlm, $width_trumb, $height_trumb, $chdimage, $hangtd;
    checkgoods();
    include("header.php");
    $urlrefl = "modules.php?name=$module_name";
    docookieclient($urlrefl);
    $tdshopresult = $db->sql_query("SELECT * FROM ".$prefix."_shop WHERE status = '1' AND pid='$hangtd'");
        $numtdshopresult = $db->sql_numrows($tdshopresult);
        if ($numtdshopresult == 1) {
        $goods = $db->sql_fetchrow($tdshopresult);
        OpenTable();
        if($goods[pic] != "") {
    if (file_exists("odules/Shop/trumb_pic/$goods[pic]")) {
    echo "<A HREF=\"javascript:CaricaFoto('modules/Shop/pic/$goods[pic]')\" BORDER=\"0\"><img style=\"float: right\" border=\"0\" src=\"modules/$module_name/trumb_pic/$goods[pic]\" width=\"$width_trumb\"></a>";
    } else { echo "<A HREF=\"javascript:CaricaFoto('modules/Shop/pic/$goods[pic]')\" BORDER=\"0\"><img style=\"float: right\" border=\"0\" src=\"modules/$module_name/pic/$goods[pic]\" width=\"$width_trumb\"></a>"; }
    } else {
    echo "<a href=modules.php?name=Shop&go=goods&pid=$goods[pid]><img border=\"0\" style=\"float: right\" src=\"modules/$module_name/images/default_02.gif\" width=150></a>";
    }
    $tdgoodstitle = $goods[title];
    $xdate = time();
   $hlm2 = $hlm * 86400;
   if (($xdate - $goods[date]) <= $hlm2) {
        	$tdgoodstitle = "<font class=storytitle>$tdgoodstitle</font> <img align=\"absbottom\" border=\"0\" src=\"modules/$module_name/themes/images/new.gif\" width=\"33\" height=\"16\">";
        	} else {
        	$tdgoodstitle = "<font class=storytitle>$tdgoodstitle</font> <img align=\"absbottom\" border=\"0\" src=\"themes/images/spacer.gif\" height=\"16\" width=\"1\">";
        	}
    echo "$tdgoodstitle<br>";
    echo ""._MAH.": $goods[addition]<br>"._MOTA.": $goods[description]<br>";
    if($goods[firm] != "") {
    if ($goods[site_firm] != "") {
    if (!eregi("http://", $goods[site_firm])) { $goods[site_firm] = "http://$goods[site_firm]"; }
    echo ""._FIRMURL.": <a href=\"$goods[site_firm]\" target=\"_blank\">$goods[firm]</a><br><br>";
    } else {
    echo ""._FIRMURL.": $goods[firm]<br>";
    }
    }
    if ($goods[action] == 1) {
    echo ""._OBPRICE.": <strike>".number_format($goods[price], 0, '.', ' ')." ".$cur."</strike>&nbsp;&nbsp;&nbsp;"._ACPRICE.": <b><font color=red>".number_format($goods[action_price], 0, '.', ' ')." ".$cur."</font></b>";
    } else { echo ""._PRICE.": <b><font color=red>".number_format($goods[price], 0, '.', ' ')." ".$cur."</font></b>"; }
    echo "&nbsp;&nbsp;&nbsp;<a href=modules.php?name=$module_name&go=basket&pid=$goods[pid]><b>"._ADDBASK."</b></a>";
   CloseTable();
   }
    $catresult = $db->sql_query("SELECT cid, cat_title, view, groups, cat_pic FROM ".$prefix."_shop_categories WHERE parentid='0' ORDER BY weight");
    while ($row = $db->sql_fetchrow($catresult)) {
        $cidcat = $row[cid];
        $titlecat = $row[cat_title];
        $titlecat = "<a href=\"modules.php?name=$module_name&go=showcat&cid=$cidcat\">$titlecat</a>";
        $cat_pic = $row[cat_pic];
        $view = $row[view];
        $groups = $row[groups];
        if ((($admin)) || ($view > 3 AND in_groups($groups)) || ($view == 3 AND !is_user($user)) || ($view == 1 AND is_user($user)) || ($view == 0)) {       
        $shopresult = $db->sql_query("SELECT * FROM ".$prefix."_shop WHERE status = '1' AND show_home= '1' AND homcid='$cidcat'  AND pid!='$hangtd' ORDER BY pid DESC LIMIT $homnum");
        $numshopresult = $db->sql_numrows($shopresult);
        if ($numshopresult > 0) {
        	echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td>";
        	gostcategoryname($titlecat, $cidcat, $cat_pic);
        	echo "</td></tr><tr><td>";
        	if ($chdimage == 1) { echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr>"; }
        	else {
        	echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
	echo "<tr><td height=\"20\" style=\"border-bottom-style: solid; border-bottom-width: 1px\"><b>"._TENH."</b></td><td style=\"border-bottom-style: solid; border-bottom-width: 1px\" width=\"20%\"><b>"._GIAH."</b></td><td style=\"border-bottom-style: solid; border-bottom-width: 1px\" width=\"30%\">&nbsp;</td></tr>";
        	}
        	while ($row2 = $db->sql_fetchrow($shopresult)) {
                   $cid = $row2[cid];
                   $catresult3 = $db->sql_query("SELECT view, groups FROM ".$prefix."_shop_categories WHERE cid='$cid'");
                   $row3 = $db->sql_fetchrow($catresult3);
                   $view3=$row3[view];
                   $groups3 = $row3[groups];
                   if ((($admin)) || ($view3 > 3 AND in_groups($groups3)) || ($view3 == 3 AND !is_user($user)) || ($view3 == 1 AND is_user($user)) || ($view3 == 0)) {
        	$goodstitle = $row2[title];
        	$pid = $row2[pid];
        	$price = $row2[price];
        	$action = $row2[action];
        	if ($action == 1) {
        	$price = $row2[action_price];
        	}
        	$addition = $row2[addition];
        	$addition = ""._MAH.": $addition";
        	$adddate = $row2[date];
        	$xdate = time();
        	$hlm2 = $hlm * 86400;
        	if (($xdate - $adddate) <= $hlm2) {
        	$goodstitle = "$goodstitle <img align=\"absbottom\" border=\"0\" src=\"modules/Shop/themes/images/new.gif\" width=\"33\" height=\"16\">";
        	} else {
        	$goodstitle = "$goodstitle <img align=\"absbottom\" border=\"0\" src=\"themes/images/spacer.gif\" height=\"16\" width=\"1\">";
        	}
        	$pic = $row2[pic];
        	$price = "".number_format($price, 0, '.', ' ')." $cur";
        	if ($pic == "") {
        	$pic = "<a href=\"modules.php?name=$module_name&go=goods&pid=$pid\"><img border=\"0\" src=\"modules/Shop/images/default_01.gif\" height=$height_trumb></a>";
        	} elseif (file_exists("modules/Shop/trumb_pic/$pic")) {
        	$pic = "<a href=\"modules.php?name=$module_name&go=goods&pid=$pid\"><img border=\"0\" src=\"modules/Shop/trumb_pic/$pic\" height=$height_trumb></a>";
        	} elseif (file_exists("modules/Shop/pic/$pic")) {
        	$pic = "<a href=\"modules.php?name=$module_name&go=goods&pid=$pid\"><img border=\"0\" src=\"modules/Shop/pic/$pic\" height=$height_trumb></a>";
                   } else {
                   	$pic = "<a href=\"modules.php?name=$module_name&go=goods&pid=$pid\"><img border=\"0\" src=\"modules/Shop/images/default_01.gif\" height=$height_trumb></a>";
                   }
        $dl = ceil(100 / $homnum);
        if ($chdimage == 1) {
        echo "<td valign=\"top\" width=\"$dl%\">";
        blockcentershop($pic, $goodstitle, $addition, $price, $pid);
        echo "</td>";
       } else {
       echo"<tr><td height=\"20\" style=\"border-bottom-style: solid; border-bottom-width: 1px\"><a href=\"modules.php?name=Shop&go=goods&pid=$pid\"><b>$goodstitle</b></a></td><td style=\"border-bottom-style: solid; border-bottom-width: 1px\"><font color=red>$price</font></td><td style=\"border-bottom-style: solid; border-bottom-width: 1px\" align=\"right\"><a href=modules.php?name=$module_name&go=goods&pid=$pid><b>"._GOODSMORE."</b></a>&nbsp;&nbsp;&nbsp;<a href=modules.php?name=$module_name&go=basket&pid=$pid><b>"._ADDBASK."</b></a></td></tr>";
       }
      }
     }
     if ($chdimage == 1) { echo"</tr></table>"; }
     else { echo "</table>"; }
     echo"</td></tr></table><br>";
     }
     }
    }
    footmenu();
    include("footer.php");
}

function cat($cid) {
    global $multilingual, $currentlang, $db, $prefix, $module_name, $bgcolor3, $cur, $admin, $user, $ThemeSel, $width_trumb, $pagenum, $scatnum, $scatstnum, $hlm, $height_trumb, $chdimage;
    checkgoods();
    $cid = intval($cid);
    include("header.php");
    docookieclient($urlrefl);
    menu($cid, $pid);
    $checkcat = $db->sql_query("SELECT view, groups FROM ".$prefix."_shop_categories WHERE cid ='$cid'");
    if ($db->sql_numrows($checkcat) != 1) { Header("Location: modules.php?name=$module_name"); exit(); }
    list($yview, $ygroups) = $db->sql_fetchrow($checkcat);
    if ((($admin)) || ($yview > 3 AND in_groups($ygroups)) || ($yview == 3 AND !is_user($user)) || ($yview == 1 AND is_user($user)) || ($yview == 0)) {
    $goodspagenum = $scatnum;
    $numgoods = $db->sql_numrows($db->sql_query("select * from ".$prefix."_shop WHERE cid ='$cid' AND status = '1'"));
    $numpages = ceil($numgoods / $goodspagenum);
    if (($pagenum=="") OR ($pagenum < 1)) { $pagenum = 1; }
    if ($pagenum > $numpages) { $pagenum = $numpages; }
    $offset = ($pagenum-1) * $goodspagenum;
    $cresult3 = $db->sql_query("SELECT * FROM ".$prefix."_shop WHERE cid ='$cid' AND status = '1' ORDER BY pid DESC limit $offset, $goodspagenum");
    if ($numrows = $db->sql_numrows($cresult3) > 0) {
    $dl = ceil(100 / $scatstnum);
    if ($chdimage == 1) {
    echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td valign=\"top\" width=\"$dl%\">";
    $cont = 0;
    } else {
    echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
    echo "<tr><td height=\"20\" style=\"border-bottom-style: solid; border-bottom-width: 1px\"><b>"._TENH."</b></td><td style=\"border-bottom-style: solid; border-bottom-width: 1px\" width=\"20%\"><b>"._GIAH."</b></td><td style=\"border-bottom-style: solid; border-bottom-width: 1px\" width=\"30%\">&nbsp;</td></tr>";
    }
    while ($crow3 = $db->sql_fetchrow($cresult3)) {
    $p_pid = intval($crow3[pid]);
    $p_title = $crow3[title];
    $p_addition = $crow3[addition];
    $p_addition = ""._MAH.": $p_addition";
    $p_description = $crow3[description];
    $p_price = $crow3[price];
    $p_action = $crow3[action];
    if ($p_action == 1) {
    if ($chdimage == 1) {
    $p_price = "<strike>".number_format($p_price, 0, '.', ' ')." ".$cur."</strike><br><b><font color=red>".number_format($crow3[action_price], 0, '.', ' ')." ".$cur."</font></b>";
    } else {
    $p_price = "<b><font color=red>".number_format($crow3[action_price], 0, '.', ' ')." ".$cur."</font></b>";
    }
    } else {
    if ($chdimage == 1) {
    $p_price = "<br><b><font color=red>".number_format($p_price, 0, '.', ' ')." $cur</font></b>";
    } else {
    $p_price = "<b><font color=red>".number_format($p_price, 0, '.', ' ')." $cur</font></b>";
    }
   }
    $p_pic = $crow3[pic];
    $adddate = $crow3[date];
        	$xdate = time();
        	if (($xdate - $adddate) <= $hlm*86400) {
        	$p_title = "<img align=\"right\" border=\"0\" src=\"modules/$module_name/themes/images/new.gif\" width=\"33\" height=\"16\">$p_title";
        	}
    if ($p_pic == "") {
    $p_pic = "<a href=\"modules.php?name=$module_name&go=goods&pid=$p_pid\"><img border=\"0\" src=\"modules/$module_name/images/default_01.gif\" height=$height_trumb></a>";
    } elseif (file_exists("modules/$module_name/trumb_pic/$p_pic")) {
        	$p_pic = "<a href=\"modules.php?name=$module_name&go=goods&pid=$p_pid\"><img border=\"0\" src=\"modules/$module_name/trumb_pic/$p_pic\" height=$height_trumb></a>";
        	} elseif (file_exists("modules/$module_name/pic/$p_pic")) {
        	$p_pic = "<a href=\"modules.php?name=$module_name&go=goods&pid=$p_pid\"><img border=\"0\" src=\"modules/$module_name/pic/$p_pic\" height=$height_trumb></a>";
                   } else {
                   	$p_pic = "<a href=\"modules.php?name=$module_name&go=goods&pid=$p_pid\"><img border=\"0\" src=\"modules/$module_name/images/default_01.gif\" height=$height_trumb></a>";
                   }
        if ($chdimage == 1) {
        blockcentershop($p_pic, $p_title, $p_addition, $p_price, $p_pid);
        $cont++;
        if ($cont < $scatstnum) { echo "</td><td valign=\"top\" width=\"$dl%\">";  }
        if ($cont == $scatstnum) { echo "</td></tr><tr><td valign=\"top\" width=\"$dl%\">"; $cont = 0; }
    } else {
    echo"<tr><td height=\"20\" style=\"border-bottom-style: solid; border-bottom-width: 1px\"><a href=\"modules.php?name=Shop&go=goods&pid=$p_pid\"><b>$p_title</b></a></td><td style=\"border-bottom-style: solid; border-bottom-width: 1px\"><font color=red>$p_price</font></td><td style=\"border-bottom-style: solid; border-bottom-width: 1px\" align=\"right\"><a href=modules.php?name=$module_name&go=goods&pid=$p_pid><b>"._GOODSMORE."</b></a>&nbsp;&nbsp;&nbsp;<a href=modules.php?name=$module_name&go=basket&pid=$p_pid><b>"._ADDBASK."</b></a></td></tr>";
    }
    }
    if ($chdimage == 1) { echo "</td></tr></table>"; } else { echo "</table>"; }
    echo "<br><br>";
    if ($numpages > 1) {
	echo "<div align=\"right\">";
	if ($pagenum > 1) {
	$prevpage = $pagenum - 1 ;
	$leftarrow = "images/left.gif";
	echo "<a href=\"modules.php?name=Shop&amp;go=cat&amp;cid=$cid&amp;pagenum=$prevpage\">";
	echo "<img src=\"$leftarrow\" align=\"absmiddle\" border=\"0\" hspace=\"10\"></a>";
	}
	for ($i=1; $i < $numpages+1; $i++) {
		if ($i == $pagenum) {
		echo "<b>$i</b>";
		} else {
		$pagelink = 5;
		if (($i > $pagenum) AND ($i < $pagenum+$pagelink) OR ($i < $pagenum) AND ($i > $pagenum-$pagelink)) {
		echo " <a href=\"modules.php?name=Shop&amp;go=cat&amp;cid=$cid&amp;pagenum=$i\">$i</a> ";
		}
		if (($i == $numpages) AND ($pagenum < $numpages-$pagelink)){
		echo "... <a href=\"modules.php?name=Shop&amp;go=cat&amp;cid=$cid&amp;pagenum=$i\">$i</a>";
		}
		if (($i == 1) AND ($pagenum > 1+$pagelink)){
		echo "<a href=\"modules.php?name=Shop&amp;go=cat&amp;cid=$cid&amp;pagenum=$i\">$i</a> ...";
		}
		}
	}
	if ($pagenum < $numpages) {
		$nextpage = $pagenum + 1 ;
		$rightarrow = "images/right.gif" ;
		echo "<a href=\"modules.php?name=Shop&amp;go=cat&amp;cid=$cid&amp;pagenum=$nextpage\">";
		echo "<img src=\"$rightarrow\" align=\"absmiddle\" border=\"0\" hspace=\"10\"></a>";
	}
	echo "</div><br>" ;
     }
    }
    }
    $catresult = $db->sql_query("SELECT cid, cat_title, cat_description, view, groups FROM ".$prefix."_shop_categories WHERE parentid='$cid' ORDER BY cid DESC");
    if ($db->sql_numrows($catresult) != 0) {
    $sc = 0;
    echo "<p><b>"._GIANH2.":</b></p>";
    while ($row = $db->sql_fetchrow($catresult)) {
        $cidcat = $row[cid];
        $titlecat = $row[cat_title];
        $cat_description = $row[cat_description];
        $titlecat = "<b>$titlecat</b>: $cat_description";
        $view = $row[view];
        $groups = $row[groups];
        if ((($admin)) || ($view > 3 AND in_groups($groups)) || ($view == 3 AND !is_user($user)) || ($view == 1 AND is_user($user)) || ($view == 0)) {
        echo "<li><a href=modules.php?name=$module_name&go=showcat&cid=$cidcat>$titlecat</a></li><hr style=\"border: 1px dotted #808080\" color=\"#000000\" size=\"1\">";
      }
    }
    echo "<br><br>";
    } else {
    Header("Location: modules.php?name=$module_name&go=showcat&cid=$cid");
    exit();
    }
    footmenu();
    include("footer.php");
}

function showcat($cid) {
    global $multilingual, $currentlang, $db, $prefix, $module_name, $bgcolor3, $cur, $admin, $user, $ThemeSel, $width_trumb, $pagenum, $scatnum, $scatstnum, $height_trumb, $chdimage;
    checkgoods();
    $cid = intval($cid);
    include("header.php");
    docookieclient($urlrefl);
    menu($cid, $pid);
    $catresult = $db->sql_query("SELECT cid, cat_title, cat_description, view, groups FROM ".$prefix."_shop_categories WHERE parentid='$cid' $querylang ORDER BY cid DESC");
    if ($db->sql_numrows($catresult) != 0) {
    Header("Location: modules.php?name=Shop&go=cat&cid=$cid");
    exit();
   }
    $checkcat = $db->sql_query("SELECT view, groups FROM ".$prefix."_shop_categories WHERE cid ='$cid'");
    if ($db->sql_numrows($checkcat) != 1) { Header("Location: modules.php?name=$module_name"); exit(); }
    list($yview, $ygroups) = $db->sql_fetchrow($checkcat);
    if ((($admin)) || ($yview > 3 AND in_groups($ygroups)) || ($yview == 3 AND !is_user($user)) || ($yview == 1 AND is_user($user)) || ($yview == 0)) {
    $goodspagenum = $scatnum;
    $numgoods = $db->sql_numrows($db->sql_query("select * from ".$prefix."_shop WHERE cid ='$cid' AND status = '1'"));
    $numpages = ceil($numgoods / $goodspagenum);
    if (($pagenum=="") OR ($pagenum < 1)) { $pagenum = 1; }
    if ($pagenum > $numpages) { $pagenum = $numpages; }
    $offset = ($pagenum-1) * $goodspagenum;
    $cresult3 = $db->sql_query("SELECT * FROM ".$prefix."_shop WHERE cid ='$cid' AND status = '1' ORDER BY pid DESC limit $offset, $goodspagenum");
    if ($numrows = $db->sql_numrows($cresult3) > 0) {
    $dl = ceil(100 / $scatstnum);
    if ($chdimage == 1) {
    echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td valign=\"top\" width=\"$dl%\">";
    $cont = 0;
    } else {
    echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
    echo "<tr><td height=\"20\" style=\"border-bottom-style: solid; border-bottom-width: 1px\"><b>"._TENH."</b></td><td style=\"border-bottom-style: solid; border-bottom-width: 1px\" width=\"20%\"><b>"._GIAH."</b></td><td style=\"border-bottom-style: solid; border-bottom-width: 1px\" width=\"30%\">&nbsp;</td></tr>";
    }
    while ($crow3 = $db->sql_fetchrow($cresult3)) {
    $p_pid = intval($crow3[pid]);
    $p_title = $crow3[title];
    $p_addition = $crow3[addition];
    $p_addition = ""._MAH.": $p_addition";
    $p_description = $crow3[description];
    $p_price = $crow3[price];
    $p_action = $crow3[action];
    if ($p_action == 1) {
    if ($chdimage == 1) {
    $p_price = "<strike>".number_format($p_price, 0, '.', ' ')." ".$cur."</strike><br><b><font color=red>".number_format($crow3[action_price], 0, '.', ' ')." ".$cur."</font></b>";
    } else {
    $p_price = "<b><font color=red>".number_format($crow3[action_price], 0, '.', ' ')." ".$cur."</font></b>";
    }
    } else {
    if ($chdimage == 1) {
    $p_price = "<br><b><font color=red>".number_format($p_price, 0, '.', ' ')." $cur</font></b>";
    } else {
    $p_price = "<b><font color=red>".number_format($p_price, 0, '.', ' ')." $cur</font></b>";
    }
   }
    $p_pic = $crow3[pic];
    $adddate = $crow3[date];
        	$xdate = time();
        	if (($xdate - $adddate) <= $hlm*86400) {
        	$p_title = "<img align=\"right\" border=\"0\" src=\"modules/$module_name/themes/images/new.gif\" width=\"33\" height=\"16\">$p_title";
        	}
    if ($p_pic == "") {
    $p_pic = "<a href=\"modules.php?name=$module_name&go=goods&pid=$p_pid\"><img border=\"0\" src=\"modules/$module_name/images/default_01.gif\" height=$height_trumb></a>";
    } elseif (file_exists("modules/$module_name/trumb_pic/$p_pic")) {
        	$p_pic = "<a href=\"modules.php?name=$module_name&go=goods&pid=$p_pid\"><img border=\"0\" src=\"modules/$module_name/trumb_pic/$p_pic\" height=$height_trumb></a>";
        	} elseif (file_exists("modules/$module_name/pic/$p_pic")) {
        	$p_pic = "<a href=\"modules.php?name=$module_name&go=goods&pid=$p_pid\"><img border=\"0\" src=\"modules/$module_name/pic/$p_pic\" height=$height_trumb></a>";
                   } else {
                   	$p_pic = "<a href=\"modules.php?name=$module_name&go=goods&pid=$p_pid\"><img border=\"0\" src=\"modules/$module_name/images/default_01.gif\" height=$height_trumb></a>";
                   }
        if ($chdimage == 1) {
        blockcentershop($p_pic, $p_title, $p_addition, $p_price, $p_pid);
        $cont++;
        if ($cont < $scatstnum) { echo "</td><td valign=\"top\" width=\"$dl%\">";  }
        if ($cont == $scatstnum) { echo "</td></tr><tr><td valign=\"top\" width=\"$dl%\">"; $cont = 0; }
    } else {
    echo"<tr><td height=\"20\" style=\"border-bottom-style: solid; border-bottom-width: 1px\"><a href=\"modules.php?name=Shop&go=goods&pid=$p_pid\"><b>$p_title</b></a></td><td style=\"border-bottom-style: solid; border-bottom-width: 1px\"><font color=red>$p_price</font></td><td style=\"border-bottom-style: solid; border-bottom-width: 1px\" align=\"right\"><a href=modules.php?name=$module_name&go=goods&pid=$p_pid><b>"._GOODSMORE."</b></a>&nbsp;&nbsp;&nbsp;<a href=modules.php?name=$module_name&go=basket&pid=$p_pid><b>"._ADDBASK."</b></a></td></tr>";
    }
    }
    if ($chdimage == 1) { echo "</td></tr></table>"; } else { echo "</table>"; }
    echo "<br><br>";
    if ($numpages > 1) {
	echo "<div align=\"right\">";
	if ($pagenum > 1) {
	$prevpage = $pagenum - 1 ;
	$leftarrow = "images/left.gif";
	echo "<a href=\"modules.php?name=Shop&amp;go=showcat&amp;cid=$cid&amp;pagenum=$prevpage\">";
	echo "<img src=\"$leftarrow\" align=\"absmiddle\" border=\"0\" hspace=\"10\"></a>";
	}
	for ($i=1; $i < $numpages+1; $i++) {
		if ($i == $pagenum) {
		echo "<b>$i</b>";
		} else {
		$pagelink = 5;
		if (($i > $pagenum) AND ($i < $pagenum+$pagelink) OR ($i < $pagenum) AND ($i > $pagenum-$pagelink)) {
		echo " <a href=\"modules.php?name=Shop&amp;go=showcat&amp;cid=$cid&amp;pagenum=$i\">$i</a> ";
		}
		if (($i == $numpages) AND ($pagenum < $numpages-$pagelink)){
		echo "... <a href=\"modules.php?name=Shop&amp;go=showcat&amp;cid=$cid&amp;pagenum=$i\">$i</a>";
		}
		if (($i == 1) AND ($pagenum > 1+$pagelink)){
		echo "<a href=\"modules.php?name=Shop&amp;go=showcat&amp;cid=$cid&amp;pagenum=$i\">$i</a> ...";
		}
		}
	}
	if ($pagenum < $numpages) {
		$nextpage = $pagenum + 1 ;
		$rightarrow = "images/right.gif" ;
		echo "<a href=\"modules.php?name=Shop&amp;go=showcat&amp;cid=$cid&amp;pagenum=$nextpage\">";
		echo "<img src=\"$rightarrow\" align=\"absmiddle\" border=\"0\" hspace=\"10\"></a>";
	}
	echo "</div><br>" ;
     }
     }
    }
    footmenu();
    include("footer.php");
}

function goods($pid) {
    global $db, $prefix, $module_name, $admin, $cur, $width_trumb, $width_trumb, $chdimage;
    checkgoods();
    $pid = intval($pid);

    $fresult = $db->sql_query("SELECT *  FROM ".$prefix."_shop WHERE pid='$pid'");
    if ($db->sql_numrows($fresult) != 1) { Header("Location: modules.php?name=$module_name"); exit(); }
    $goods = $db->sql_fetchrow($fresult);
    list($yview, $ygroups) = $db->sql_fetchrow($db->sql_query("SELECT view, groups FROM ".$prefix."_shop_categories WHERE cid ='$goods[cid]'"));
    if ((($admin)) || ($yview > 3 AND in_groups($ygroups)) || ($yview == 3 AND !is_user($user)) || ($yview == 1 AND is_user($user)) || ($yview == 0)) {
    include("header.php");
    docookieclient($urlrefl);
    menu($goods[cid], $pid);
    OpenTable();
    if($goods[pic] != "") {
    if (file_exists("modules/Shop/trumb_pic/$goods[pic]")) {
    echo "<A HREF=\"javascript:CaricaFoto('modules/Shop/pic/$goods[pic]')\" BORDER=\"0\"><img style=\"float: right\" border=\"0\" src=\"modules/Shop/trumb_pic/$goods[pic]\" width=\"$width_trumb\"></a>";
    } else { echo "<A HREF=\"javascript:CaricaFoto('modules/Shop/pic/$goods[pic]')\" BORDER=\"0\"><img style=\"float: right\" border=\"0\" src=\"modules/Shop/pic/$goods[pic]\" width=\"$width_trumb\"></a>"; }
    } else {
        if ($chdimage == 1) {
    echo "<img border=\"0\" style=\"float: right\" src=\"modules/$module_name/images/default_02.gif\" width=150></a>";
    }
    }
    echo "<font class=storytitle>$goods[title]</font><br>";
    echo ""._MAH.": $goods[addition]<br>"._MOTA.": $goods[description]<br>";
    if($goods[firm] != "") {
    if ($goods[site_firm] != "") {
    if (!eregi("http://", $goods[site_firm])) { $goods[site_firm] = "http://$goods[site_firm]"; }
    echo ""._FIRMURL.": <a href=\"$goods[site_firm]\" target=\"_blank\">$goods[firm]</a><br><br>";
    } else {
    echo ""._FIRMURL.": $goods[firm]<br>";
    }
    }
    if ($goods[action] == 1) {
    echo ""._OBPRICE.": <strike>".number_format($goods[price], 0, '.', ' ')." ".$cur."</strike>&nbsp;&nbsp;&nbsp;"._ACPRICE.": <b><font color=red>".number_format($goods[action_price], 0, '.', ' ')." ".$cur."</font></b>";
    } else { echo ""._PRICE.": <b><font color=red>".number_format($goods[price], 0, '.', ' ')." ".$cur."</font></b>"; }
    echo "&nbsp;&nbsp;&nbsp;<a href=modules.php?name=$module_name&go=basket&pid=$goods[pid]><b>"._ADDBASK."</b></a>";
    CloseTable();
    if (($admin)) {
    OpenTable();
    echo "<br><center><b>"._ADMINSG."</b><br><br><a href=admin/admin.php?op=shop_delit_goods&pid=$pid>"._DELPAGE."</a> | <a href=admin/admin.php?op=shop_edit_goods&pid=$pid>"._EDITPAGE."</a> | <a href=admin/admin.php?op=shop_status_goods&pid=$pid&act=off>"._OFFPAGE."</a></center><br>";
    CloseTable();
    }
    $hresult = $db->sql_query("SELECT *  FROM ".$prefix."_shop WHERE pid!='$goods[pid]' AND cid='$goods[cid]' ORDER BY pid DESC LIMIT 20");
    if ($db->sql_numrows($hresult) != 0) {
    echo "<br><center><b>"._SPCUNGL."</b></center><br>";
    echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
    echo "<tr><td height=\"20\" style=\"border-bottom-style: solid; border-bottom-width: 1px\"><b>"._TENH."</b></td><td style=\"border-bottom-style: solid; border-bottom-width: 1px\" width=\"20%\"><b>"._GIAH."</b></td><td style=\"border-bottom-style: solid; border-bottom-width: 1px\" width=\"30%\">&nbsp;</td></tr>";
    while ($hrow = $db->sql_fetchrow($hresult)) {
    $gia = "".number_format($hrow[price], 0, '.', ' ')." ".$cur."";
    if ($hrow[action] == 1) {
    $gia = "".number_format($hrow[action_price], 0, '.', ' ')." ".$cur."";
    }
    echo"<tr><td height=\"20\" style=\"border-bottom-style: solid; border-bottom-width: 1px\"><a href=\"modules.php?name=Shop&go=goods&pid=$hrow[pid]\"><b>$hrow[title]</b></a></td><td style=\"border-bottom-style: solid; border-bottom-width: 1px\"><font color=red>$gia</font></td><td style=\"border-bottom-style: solid; border-bottom-width: 1px\" align=\"right\"><a href=modules.php?name=$module_name&go=goods&pid=$hrow[pid]><b>"._GOODSMORE."</b></a>&nbsp;&nbsp;&nbsp;<a href=modules.php?name=$module_name&go=basket&pid=$hrow[pid]><b>"._ADDBASK."</b></a></td></tr>";
    }
    echo "</table><br>";
    }
    footmenu();
    include("footer.php");
} else {
   Header("Location: modules.php?name=$module_name"); exit();
}
}

function basket($pid) {
    global $db, $prefix, $user, $cookie, $module_name, $cur, $ThemeSel, $hle;
    checkgoods();
    include("header.php");
    docookieclient($urlrefl);
    $hle2 = $hle * 86400;
    $past_time = time() - $hle2;
    $db->sql_query("DELETE FROM ".$prefix."_shop_usercat WHERE g_date < '$past_time'");
    $client = $_COOKIE["client"];
    $client = base64_decode($client);
    if ($client == "") { Header("Location: modules.php?name=$module_name"); exit(); }
    $pid = intval($pid);
    $cid= "basket";
    menu($cid, $pid);
    OpenTable();
    if($pid != 0) {
    $gresult = $db->sql_query("SELECT * FROM ".$prefix."_shop WHERE pid='$pid'");
    $goods = $db->sql_fetchrow($gresult);
    $testg = $db->sql_numrows($gresult);
    if ($testg != 1) { Header("Location: modules.php?name=$module_name"); exit(); }
    $gnnn = $db->sql_query("SELECT * FROM ".$prefix."_shop_usercat WHERE g_uname='$client' AND g_pid='$goods[pid]'");
    $g2nnn = $db->sql_fetchrow($gnnn);
    $nnn = $db->sql_numrows($gnnn);
    if ($nnn == 0) {
    if($goods[action] == 1) { $price = $goods[action_price]; }
    else { $price = $goods[price]; }
    $xdate = time();
    $db->sql_query("INSERT INTO ".$prefix."_shop_usercat (gid, g_uname, g_pid, g_title, g_price, g_count, g_date) VALUES (NULL, '$client', '$goods[pid]', '$goods[title]', '$price', '1', '$xdate')");
    } else {
    $gidnnn = $g2nnn[gid];
    $gcountnnn = $g2nnn[g_count];
    $gcountnnn = $gcountnnn+1;
    $db->sql_query("UPDATE ".$prefix."_shop_usercat SET g_count='$gcountnnn' WHERE gid='$gidnnn'");
    }
    }
    $gresult2 = $db->sql_query("SELECT * FROM ".$prefix."_shop_usercat WHERE g_uname='$client'");
    $num = $db->sql_numrows($gresult2);
    if ($num > 0) {
    $total_sum = 0;
    $hangtd = "";
    echo "<form method=\"POST\" action=\"modules.php?name=$module_name\">";
    echo"<table border=\"1\" width=\"100%\" style=\"border-collapse: collapse\" cellspacing=\"3\"><tr>\n"
."<td align=\"center\"><b>"._TENH."</b></td>\n"
."<td align=\"center\"><b>"._GIAH."</b></td>\n"
."<td align=\"center\"><b>"._COUNT."</b></td>\n"
."<td align=\"center\"><b>"._ALLSUM."</b></td>\n"
."<td align=\"center\"><b>"._DELPAGE."</b></td>\n</tr>\n";
    while ($row = $db->sql_fetchrow($gresult2)) {
    $tenhang = "<a href=modules.php?name=$module_name&go=goods&pid=$row[g_pid]>$row[g_title]</a>";
    $idhang = $row['g_pid'];
    $id2hang = $row['gid'];
    $gia = $row['g_price'];
    $giahang = number_format($row['g_price'], 0, '.', ' ');
    $soluong = $row['g_count']; 
    $suma = $gia*$soluong;
    $thanhtien = number_format($suma, 0, '.', ' ');
    echo"<input type=\"hidden\" name=\"gid[]\" value=\"$id2hang\">$hangtd<tr><td align=\"center\">$tenhang</td><td align=\"center\">$giahang</td><td align=\"center\"><input type=\"text\" name=\"count[]\" size=\"1\" value=\"$soluong\"></td><td align=\"center\">$thanhtien</td><td align=\"center\"><input type=\"checkbox\" name=\"id2[]\" value=\"$id2hang\"></td></tr>\n";
    $total_sum = $total_sum+$suma;
    }
    $total_sum2 = number_format($total_sum, 0, '.', ' ');
    $total_sum2 = "$total_sum2 $cur";
    echo "<tr><td colspan=\"3\" align=\"right\"><b>"._ALLBAY.":</b></td><td colspan=\"2\" align=\"center\"><b>$total_sum2</b></td></tr>\n</table>\n\n";
    echo "<p align=\"center\"><input type=\"hidden\" name=\"go\" value=\"count_change\">";
    echo "<input type=\"submit\" value=\"" . _SHOPSTL . "\">";
    echo "&nbsp;&nbsp;<input type=\"button\" value=\""._CLEARBACK."\" title=\""._CLEARBACK."\" onClick=\"window.location='modules.php?name=$module_name&go=clear_backen'\">";
    echo "&nbsp;&nbsp;<input type=\"button\" value=\""._SHOPSADDS."\" title=\""._SHOPSADDS."\" onClick=\"window.location='modules.php?name=$module_name'\">";
    echo "&nbsp;&nbsp;<input type=\"button\" value=\""._SENDORDER."\" title=\""._SENDORDER."\" onClick=\"window.location='modules.php?name=$module_name&go=order_goods'\">";
    echo"</p></form>";
    } else {
    echo "<br><br><br><center><b>"._BASCKETNULL."</b></center><br><br><br>";
    }
    CloseTable();
    footmenu();
    include("footer.php");
}

function count_change($id2, $gid, $count) {
    global $db, $prefix, $module_name;
    $client = $_COOKIE["client"];
    $client = base64_decode($client);
    if ($client == "") { Header("Location: modules.php?name=$module_name"); exit(); }
    for ($i=0; $i < sizeof($gid); $i++) {
    	if ($count[$i] <= 0) {
	$db->sql_query("DELETE FROM ".$prefix."_shop_usercat WHERE gid='$gid[$i]'");
    	} else {
    	$db->sql_query("UPDATE ".$prefix."_shop_usercat SET g_count='$count[$i]' WHERE gid='$gid[$i]'");
    	}
    }
    for ($y=0; $y < sizeof($id2); $y++) {
    	$db->sql_query("DELETE FROM ".$prefix."_shop_usercat WHERE gid='$id2[$y]'");
   }
    Header("Location: modules.php?name=$module_name&go=basket");
}

function clear_backen() {
    global $db, $prefix, $module_name;
    $client = $_COOKIE["client"];
    $client = base64_decode($client);
    if ($client != "") {
    $db->sql_query("DELETE FROM ".$prefix."_shop_usercat WHERE g_uname='$client'");
    Header("Location: modules.php?name=$module_name&go=basket");
    }  else {
    Header("Location: modules.php?name=$module_name");
    }
}

function order_goods() {
    global $db, $prefix, $user_prefix, $cookie, $user, $module_name, $cur, $sitekey, $gfx_chk, $phthth;
     checkgoods();
    docookieclient($urlrefl);
    $client = $_COOKIE["client"];
    $client = base64_decode($client);
    if ($client == "") { Header("Location: modules.php?name=$module_name"); exit(); }
    $a = 0;
    $sum = 0;
    $dresult = $db->sql_query("SELECT * FROM ".$prefix."_shop_usercat WHERE g_uname='$client'");
    $num = $db->sql_numrows($dresult);
    while ($order = $db->sql_fetchrow($dresult)) {
    $goods[$a] = "$order[g_title]|$order[g_price]|$order[g_count]";
    $sum = $sum+$order[g_price]*$order[g_count];
    $a++;
    }
    include("header.php");
    $cid= "basket";
    menu($cid, $pid);
    OpenTable();
    echo "<center><b>"._YOURORDER.":</b></center><br><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
    for($p=0; $p<$num; $p++) {
    $ord = explode("|", $goods[$p]);
    $tt = $p+1; $tt = "$tt. ";
    echo "<tr><td>".$tt."$ord[0]</td><td>"._PRICE.": ".number_format($ord[1], 0, '.', ' ')."</td><td>"._COUNT.": $ord[2]</td></tr>";
    }
    echo "</table><br><table><tr><td><b>"._ALLCOUNT.": </b></td><td align=\"right\"><font color=red><b>".number_format($sum, 0, '.', ' ')." ".$cur."</b></font></td></tr>";
    echo "</table><br><hr><br>";
    echo "<center><b>"._HUONGDAN2."</b></center><p align=\"justify\">$phthth<br><hr><br>";
    cookiedecode($user);
    getusrinfo($user);
    echo "<a name=\"1\"></a>";
    if (($userinfo[username] != $cookie[1]) AND ($userinfo[user_password] != $cookie[2])) {
    echo "<b>"._SHOPSADDSUSER."</b>:<br>";
        list($user_id, $name, $user_email, $user_telephone, $user_from) = $db->sql_fetchrow($db->sql_query("SELECT user_id, name, user_email, user_telephone, user_from FROM ".$user_prefix."_users WHERE username='$cookie[1]'"));
        echo "<table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"5\">";
        if ($name!="") echo "<tr><td>"._TENKH.": </td><td>$name</td></tr>\n";
        echo "<tr><td>"._TENTRC.": </td><td><a href=\"modules.php?name=Your_Account&op=userinfo&username=$cookie[1]\">$cookie[1]</a></td></tr>\n";
        echo "<tr><td>"._EMAILKH.": </td><td><a href=\"mailto:$user_email\">$user_email</a></td></tr>\n";
        if ($user_telephone!="") echo "<tr><td>"._TELKH.": </td><td>$user_telephone</td></tr>\n";
        if ($user_from!="") echo "<tr><td>"._ADDRESSKH.": </td><td>$user_from</td></tr>\n";
        echo "</table><br>\n";

    echo "<center><table><tr><td><form method=\"POST\" action=\"modules.php?name=$module_name\">"
    ."<input type=\"hidden\" name=\"go\" value=\"order_send\">"
    ."<input type=\"submit\" value=\""._SENDORDER."\"></form></td><td>"
    ."<form method=\"POST\" action=\"modules.php?name=$module_name\">"
    ."<input type=\"hidden\" name=\"go\" value=\"basket\">"
    ."<input type=\"submit\" value=\""._NOORDERSEND."\"></form></td></tr></table></center>";
    } else {
    require_once ("modules/Shop/ya_config.php");
    echo "<center><b>"._SHOPSADDSUSER2."</b>:</center><br>";
    mt_srand ((double)microtime()*1000000);
    $maxran = 1000000;
    $random_num2 = mt_rand(0, $maxran);
    echo "<form action=\"modules.php?name=Your_Account\" method=\"post\">";
    echo "<center><table border=\"0\" cellpadding=\"0\" cellspacing=\"1\">";
    echo "<tr><td><font class=\"content\">"._NICKNAME.": </td><td>";
    echo "<input type=\"text\" name=\"username\" size=\"15\" maxlength=\"25\"></td>";
    echo "<td align=\"right\">"._PASSWORD.": </td><td>";
    echo "<input type=\"password\" name=\"user_password\" size=\"15\" maxlength=\"20\"></td></tr>";
    if (extension_loaded("gd") AND ($gfx_chk == 2 OR $gfx_chk == 4 OR $gfx_chk == 5 OR $gfx_chk == 7)) {
    echo "<tr><td>"._SECURITYCODE.": </td><td><img src='modules.php?name=Your_Account&op=gfx&random_num=$random_num2' border='1' alt='"._SECURITYCODE."' title='"._SECURITYCODE."'></td>\n";
    echo "<td align=\"right\">"._TYPESECCODE.": </td><td><input type=\"text\" NAME=\"gfx_check\" SIZE=\"15\" MAXLENGTH=\"6\"></td></tr>\n";
    echo "<input type=\"hidden\" name=\"random_num\" value=\"$random_num2\">\n";
    } else {
    echo "<input type=\"hidden\" name=\"random_num\" value=\"$random_num2\">";
    echo "<input type=\"hidden\" name=\"gfx_check\" value=\"$code\">";
    }
    echo "<tr><td colspan=4 align=\"center\">"._REMEMBER." <input type=\"checkbox\" name=\"remember\" value=\"1\"> <input type=\"submit\" value=\""._LOGIN."\"></td></tr>";
    echo "<input type=\"hidden\" name=\"userredirect2\" value=\"$module_name&go=order_goods#1\">";
    echo "<input type=\"hidden\" name=\"op\" value=\"login\">";
    echo "</td></tr></table></font><center></form><br><br>";
    echo "<center><b>"._SHOPSADDSUSER3.":</b><br>("._SHOPSADDSUSER4.")</center><br>";

        $random_num = mt_rand(0, $maxran);
        echo "<form action=\"modules.php?name=Your_Account\" method=\"post\">\n";
        echo "<center><table cellpadding=\"0\" cellspacing=\"2\" border=\"0\">\n";
        if ($kb_urealname == 1) { echo "<tr><td>"._UREALNAME.":</td><td><input type=\"text\" name=\"realname\" size=\"30\" maxlength=\"60\"></td></tr>\n"; } else { echo "<input type=\"hidden\" name=\"realname\" value=\"\">\n"; }
        if ($kb_ureallastname == 1) { echo "<tr><td>"._UREALLASTNAME.":</td><td><input type=\"text\" name=\"lastname\" size=\"30\" maxlength=\"60\"></td></tr>\n"; } else { echo "<input type=\"hidden\" name=\"lastname\" value=\"\">\n"; }
        if ($kb_ylocation == 1) { echo "<tr><td>"._YLOCATION.":</td><td><input type=\"text\" name=\"user_from\" size=\"30\" maxlength=\"100\"></td></tr>\n"; } else { echo "<input type=\"hidden\" name=\"user_from\" value=\"\">\n"; }
        if ($kb_ytelephone == 1) { echo "<tr><td>"._YTELEPHONE.":</td><td><input type=\"text\" name=\"user_telephone\" size=\"30\" maxlength=\"20\"></td></tr>\n"; } else { echo "<input type=\"hidden\" name=\"user_telephone\" value=\"\">\n"; }
        if ($kb_yicq == 1) { echo "<tr><td>"._YICQ.":</td><td><input type=\"text\" name=\"user_icq\" size=\"30\" maxlength=\"20\"></td></tr>\n"; } else { echo "<input type=\"hidden\" name=\"user_icq\" value=\"\">\n"; }
        if ($kb_yinterests == 1) { echo "<tr><td>"._YINTERESTS.":</td><td><input type=\"text\" name=\"user_interests\" size=\"30\" maxlength=\"255\"></td></tr>\n"; } else { echo "<input type=\"hidden\" name=\"user_interests\" value=\"\">\n"; }
        if ($kb_ysignature == 1) { echo "<tr><td>"._YSIGNATURE.":</td><td><textarea  cols=\"29\" rows=\"5\" name=\"user_sig\"></textarea></td></tr>\n"; } else { echo "<input type=\"hidden\" name=\"user_sig\" value=\"\">\n"; }
        if ($kb_yourhomepage == 1) { echo "<tr><td>"._YOURHOMEPAGE.":</td><td><input type=\"text\" name=\"user_website\" size=\"30\" maxlength=\"255\"></td></tr>\n"; } else { echo "<input type=\"hidden\" name=\"user_website\" value=\"\">\n"; }
        echo "<tr><td>"._NICKNAME.":<font color=red>*</font></td><td><input type=\"text\" name=\"username\" size=\"30\" maxlength=\"$nick_max\"></td></tr>\n"
            ."<tr><td>"._EMAIL.":<font color=red>*</font></td><td><input type=\"text\" name=\"user_email\" size=\"30\" maxlength=\"255\"></td></tr>\n";
        if ($kb_password == 1) { echo "<tr><td>"._PASSWORD.":</td><td><input type=\"password\" name=\"user_password\" size=\"30\" maxlength=\"$pass_max\"></td></tr>\n<tr><td>"._RETYPEPASSWORD.":</td><td><input type=\"password\" name=\"user_password2\" size=\"30\" maxlength=\"$pass_max\"></td></tr>\n"; }
        else { echo "<input type=\"hidden\" name=\"user_password\" value=\"\"><input type=\"hidden\" name=\"user_password2\" value=\"\">\n"; }
        if (extension_loaded("gd") AND ($gfx_chk == 3 OR $gfx_chk == 4 OR $gfx_chk == 6 OR $gfx_chk == 7)) {
            echo "<tr><td>"._SECURITYCODE.":</td><td><img src='modules.php?name=Your_Account&op=gfx&random_num=$random_num' border='1' alt='"._SECURITYCODE."' title='"._SECURITYCODE."'></td></tr>\n"
                ."<tr><td>"._TYPESECCODE.":<font color=red>*</font></td><td><input type=\"text\" NAME=\"gfx_check\" SIZE=\"11\" MAXLENGTH=\"6\"></td></tr>\n"
                ."<input type=\"hidden\" name=\"random_num\" value=\"$random_num\">\n";
        }
        echo "<tr><td colspan='2' align=center>\n"
            ."<input type=\"hidden\" name=\"op\" value=\"new user\">\n"
            ."<br><input type=\"submit\" value=\""._NEWUSER."\">\n"
            ."</td></tr></table></center>\n"
            ."</form>\n";
    }
    CloseTable();
    footmenu();
    include("footer.php");
}

function order_send() {
    global $db, $prefix, $user_prefix, $cookie, $user, $module_name, $sitename, $adminmail, $nukeurl, $cur, $phthth;
    $client = $_COOKIE["client"];
    $client = base64_decode($client);
    if ($client == "") { Header("Location: modules.php?name=$module_name"); exit(); }
    cookiedecode($user);
    getusrinfo($user);
    if (($userinfo[username] != $cookie[1]) AND ($userinfo[user_password] != $cookie[2])) {
    $a = 0;
    $sum = 0;
    $bresult = $db->sql_query("SELECT * FROM ".$prefix."_shop_usercat WHERE g_uname='$client'");
    $num = $db->sql_numrows($bresult);
    while ($order = $db->sql_fetchrow($bresult)) {
    $goods[$a] = "$order[g_title]|$order[g_price]|$order[g_count]";
    $sum = $sum+($order[g_price]*$order[g_count]);
    $a++;
    }
    $msg = "";
    $base = "";
    for($p=0; $p < $num; $p++) {
    $ord = explode("|", $goods[$p]);
    $msg .= "$ord[0] | "._PRICE.": ".number_format($ord[1], 0, '.', ' ')." ".$cur." | "._COUNT.": $ord[2]<br>";
    if ($base == "") {
    $base .= "$ord[0]|".number_format($ord[1], 0, '.', ' ')."|$ord[2]";
    } else {
    $base .= "<=>$ord[0]|".number_format($ord[1], 0, '.', ' ')."|$ord[2]";
    }
    }
    $sum2 = $sum;
    $sum = number_format($sum, 0, '.', ' ');
    $xdate = time();
    $res = $db->sql_query("INSERT INTO ".$prefix."_shop_orders (order_id, order_uname, order_text, order_sum, order_date) VALUES (NULL, '$cookie[1]', '$base', '$sum2', '$xdate')");
    if($res) {
    $db->sql_query("DELETE FROM ".$prefix."_shop_usercat WHERE g_uname = '$client'");
    $client = base64_encode("$client");
    setcookie("client","$client",time() + 1209600);
    }
        list($name, $username, $lastname, $user_email, $user_telephone) = $db->sql_fetchrow($db->sql_query("SELECT name, username, lastname, user_email, user_telephone FROM ".$user_prefix."_users WHERE username='$cookie[1]'"));
                   $subject = "The order from your site";
	$msgtext = ""._ORDERGOODSSEND."<br><br>";
	$msgtext .= "$msg<br><br>";
	$msgtext .= ""._ALLCOUNT.": $sum ".$cur."<br><br>";
	$msgtext .= ""._SENDERDATA.":<br>Login - $username<br>E-mail - $user_email<br>";
	if ($lastname != "") {
	$msgtext .= "Last Name - $lastname<br>";
	}
	if ($name != "") {
	$msgtext .= "First Name - $name<br>";
	}
	if ($user_telephone != "") {
	$msgtext .= "Telephon - $user_telephone<br>";
	}
	$to = $adminmail;
	$mailheaders = "Content-Type: text/html; charset="._CHARSET."\n";
	$mailheaders .= "From: $username <$user_email>\n";
	mail($to, $subject, $msgtext, $mailheaders);
	
	$subject = "Confirmation in reception of the order";
	$msgtext = "$username!<br>"._NOTIFYORDER."<br><br>";
	$msgtext .= ""._ORDERDETAILS."<br><br>";
	$msgtext .= "$msg<br><br>";
	$msgtext .= ""._ALLCOUNT.": $sum ".$cur."<br><br>";
	$msgtext .= "$phthth<br><br><br>"._SENDSENCKS."<br>";
	$msgtext .= "<a href=$nukeurl>$sitename</a><br>";
	$to = $user_email;
	$mailheaders = "Content-Type: text/html; charset="._CHARSET."\n";
	$mailheaders .= "From: $sitename <$adminmail>\n";
	mail($to, $subject, $msgtext, $mailheaders);
	
	
    include("header.php");
    $cid= "basket";
    menu($cid, $pid);
    OpenTable();
    echo "<br><br><center><b>"._SENCKS."</b><br><br>";
    echo "<b>"._ORDERGOODSEND."</b><br><br>"._ORDERGOODSEND2."</center>";
    echo "<META HTTP-EQUIV=\"refresh\" content=\"2;URL=modules.php?name=Shop\">";
    CloseTable();
    footmenu();
    include("footer.php");
    } else {
    Header("Location: modules.php?name=$module_name");
    }
}

function order_history() {
    global $db, $prefix, $user, $cookie, $module_name, $cur, $sitekey, $gfx_chk, $hourdiff;
    $timeadjust = ($hourdiff * 60 * 60);
    include("header.php");
    docookieclient($urlrefl);
    $pid = intval($pid);
    $cid= "basket";
    menu($cid, $pid);
    OpenTable();
    cookiedecode($user);
    getusrinfo($user);
    if (($userinfo[username] != $cookie[1]) AND ($userinfo[user_password] != $cookie[2])) {
    
    $gresult = $db->sql_query("SELECT * FROM ".$prefix."_shop_orders WHERE order_uname='$cookie[1]'");
    $num = $db->sql_numrows($gresult);
    if ($num == 0) {
    echo "<center><br><br><b>"._NOUORDERS."</b><br><br></center>";
    } else {
    echo "<table width=\"100%\" border=\"1\" cellpadding=\"4\" cellspacing=\"0\"><tr bgcolor=#EFEFEF><td width=50%><b>"._ORDERTEXTS."</td><td align=center><b>"._ALLSUM."</td><td align=center><b>"._ORDERDATE."</td><td align=center><b>"._ORSTATUS."</b></td></tr>";
    while ($orders = $db->sql_fetchrow($gresult)) {
    $ord_text = explode("<=>", $orders[order_text]);
    if ($b == 1) { $bg = "bgcolor=\"#EFEFEF\""; }
    else { $bg = ""; }
    echo "<tr $bg><td valign=top>";
    for($p=0; $p<count($ord_text); $p++) {
    echo "- $ord_text[$p]<br>";
    }
    if ($orders[order_status ] == 1) { $status = "".date("j.n.Y",$orders[confor_date]+$timeadjust).""; }
    if ($orders[order_status ] == 0) { $status = ""._ORWAIT.""; }
    echo "</td><td align=center>".number_format($orders[order_sum], 0, '.', ' ')." $cur</td><td align=center>".date("j.n.Y",$orders[order_date]+$timeadjust)."</td><td align=center>$status</td></tr>";
    $b++; if ($b==2) { $b=0; }
    }
    echo "</table><br>";
    }
    } else {
    require_once("modules/Shop/ya_config.php");
    mt_srand ((double)microtime()*1000000);
    $maxran = 1000000;
    $random_num2 = mt_rand(0, $maxran);
    echo "<br><br><form action=\"modules.php?name=Your_Account\" method=\"post\">";
    echo "<center><table border=\"0\" cellpadding=\"0\" cellspacing=\"1\">";
    echo "<tr><td><font class=\"content\">"._NICKNAME.": </td><td>";
    echo "<input type=\"text\" name=\"username\" size=\"15\" maxlength=\"25\"></td>";
    echo "<td align=\"right\">"._PASSWORD.": </td><td>";
    echo "<input type=\"password\" name=\"user_password\" size=\"15\" maxlength=\"20\"></td></tr>";
    if (extension_loaded("gd") AND ($gfx_chk == 2 OR $gfx_chk == 4 OR $gfx_chk == 5 OR $gfx_chk == 7)) {
    echo "<tr><td>"._SECURITYCODE.": </td><td><img src='modules.php?name=Your_Account&op=gfx&random_num=$random_num2' border='1' alt='"._SECURITYCODE."' title='"._SECURITYCODE."'></td>\n";
    echo "<td align=\"right\">"._TYPESECCODE.": </td><td><input type=\"text\" NAME=\"gfx_check\" SIZE=\"15\" MAXLENGTH=\"6\"></td></tr>\n";
    echo "<input type=\"hidden\" name=\"random_num\" value=\"$random_num2\">\n";
    } else {
    echo "<input type=\"hidden\" name=\"random_num\" value=\"$random_num2\">";
    echo "<input type=\"hidden\" name=\"gfx_check\" value=\"$code\">";
    }
    echo "<tr><td colspan=4 align=\"center\">"._REMEMBER." <input type=\"checkbox\" name=\"remember\" value=\"1\"> <input type=\"submit\" value=\""._LOGIN."\"></td></tr>";
    echo "<input type=\"hidden\" name=\"userredirect2\" value=\"$module_name&go=order_history\">";
    echo "<input type=\"hidden\" name=\"op\" value=\"login\">";
    echo "</td></tr></table></font><center></form><br><br>";
    }
    CloseTable();
    footmenu();
    include("footer.php");
}

function action() {
    global $db, $prefix, $module_name, $cur, $admin, $user, $ThemeSel, $width_trumb, $pagenum, $scatnum, $scatstnum, $hlm, $height_trumb, $chdimage;
    checkgoods();
    include("header.php");
    docookieclient($urlrefl);
    $cid = "action";
    menu($cid, $pid);
    $goodspagenum = $scatnum;
    $numgoods = $db->sql_numrows($db->sql_query("select * from ".$prefix."_shop WHERE action='1'"));
    $numpages = ceil($numgoods / $goodspagenum);
    if (($pagenum=="") OR ($pagenum < 1)) { $pagenum = 1; }
    if ($pagenum > $numpages) { $pagenum = $numpages; }
    $offset = ($pagenum-1) * $goodspagenum;
    $cresult3 = $db->sql_query("SELECT * FROM ".$prefix."_shop WHERE action = '1' ORDER BY pid DESC limit $offset, $goodspagenum");
    if ($numrows = $db->sql_numrows($cresult3) > 0) {
    $dl = ceil(100 / $scatstnum);
    if ($chdimage == 1) {
    echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td valign=\"top\" width=\"$dl%\">";
    $cont = 0;
    } else {
    echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
    echo "<tr><td height=\"20\" style=\"border-bottom-style: solid; border-bottom-width: 1px\"><b>"._TENH."</b></td><td style=\"border-bottom-style: solid; border-bottom-width: 1px\" width=\"30%\"><b>"._GIAH."</b></td><td style=\"border-bottom-style: solid; border-bottom-width: 1px\" width=\"30%\">&nbsp;</td></tr>";
    }
    while ($crow3 = $db->sql_fetchrow($cresult3)) {
    $p_pid = intval($crow3[pid]);
    $p_title = $crow3[title];
    $p_addition = $crow3[addition];
    $p_addition = ""._MAH.": $p_addition";
    $p_description = $crow3[description];
    $p_price = $crow3[price];
    $p_action = $crow3[action];
    if ($chdimage == 1) {
    $p_price = "<strike>".number_format($p_price, 0, '.', ' ')." ".$cur."</strike><br><b><font color=red>".number_format($crow3[action_price], 0, '.', ' ')." ".$cur."</font></b>";
    } else {
    $p_price = "<strike>".number_format($p_price, 0, '.', ' ')." ".$cur."</strike> <b><font color=red>".number_format($crow3[action_price], 0, '.', ' ')." ".$cur."</font></b>";
    }
    $p_pic = $crow3[pic];
    $adddate = $crow3[date];
        	$xdate = time();
        	if (($xdate - $adddate) <= $hlm*86400) {
        	$p_title = "<img align=\"right\" border=\"0\" src=\"modules/$module_name/themes/images/new.gif\" width=\"33\" height=\"16\">$p_title";
        	}
    if ($p_pic == "") {
    $p_pic = "<a href=\"modules.php?name=$module_name&go=goods&pid=$p_pid\"><img border=\"0\" src=\"modules/$module_name/images/default_01.gif\" height=$height_trumb></a>";
    } elseif (file_exists("modules/$module_name/trumb_pic/$p_pic")) {
        	$p_pic = "<a href=\"modules.php?name=$module_name&go=goods&pid=$p_pid\"><img border=\"0\" src=\"modules/$module_name/trumb_pic/$p_pic\" height=$height_trumb></a>";
        	} elseif (file_exists("modules/$module_name/pic/$p_pic")) {
        	$p_pic = "<a href=\"modules.php?name=$module_name&go=goods&pid=$p_pid\"><img border=\"0\" src=\"modules/$module_name/pic/$p_pic\" height=$height_trumb></a>";
                   } else {
                   	$p_pic = "<a href=\"modules.php?name=$module_name&go=goods&pid=$p_pid\"><img border=\"0\" src=\"modules/$module_name/images/default_01.gif\" height=$height_trumb></a>";
                   }
        if ($chdimage == 1) {
        blockcentershop($p_pic, $p_title, $p_addition, $p_price, $p_pid);
        $cont++;
        if ($cont < $scatstnum) { echo "</td><td valign=\"top\" width=\"$dl%\">";  }
        if ($cont == $scatstnum) { echo "</td></tr><tr><td valign=\"top\" width=\"$dl%\">"; $cont = 0; }
    } else {
    echo"<tr><td height=\"20\" style=\"border-bottom-style: solid; border-bottom-width: 1px\"><a href=\"modules.php?name=Shop&go=goods&pid=$p_pid\"><b>$p_title</b></a></td><td style=\"border-bottom-style: solid; border-bottom-width: 1px\"><font color=red>$p_price</font></td><td style=\"border-bottom-style: solid; border-bottom-width: 1px\" align=\"right\"><a href=modules.php?name=$module_name&go=goods&pid=$p_pid><b>"._GOODSMORE."</b></a>&nbsp;&nbsp;&nbsp;<a href=modules.php?name=$module_name&go=basket&pid=$p_pid><b>"._ADDBASK."</b></a></td></tr>";
    }
    }
    if ($chdimage == 1) { echo "</td></tr></table>"; } else { echo "</table>"; }
    echo "<br><br>";
   }
    if ($numpages > 1) {
	echo "<div align=\"right\">";
	if ($pagenum > 1) {
	$prevpage = $pagenum - 1 ;
	$leftarrow = "images/left.gif";
	echo "<a href=\"modules.php?name=Shop&amp;go=action&amp;pagenum=$prevpage\">";
	echo "<img src=\"$leftarrow\" align=\"absmiddle\" border=\"0\" hspace=\"10\"></a>";
	}
	for ($i=1; $i < $numpages+1; $i++) {
		if ($i == $pagenum) {
		echo "<b>$i</b>";
		} else {
		$pagelink = 5;
		if (($i > $pagenum) AND ($i < $pagenum+$pagelink) OR ($i < $pagenum) AND ($i > $pagenum-$pagelink)) {
		echo " <a href=\"modules.php?name=Shop&amp;go=action&amp;pagenum=$i\">$i</a> ";
		}
		if (($i == $numpages) AND ($pagenum < $numpages-$pagelink)){
		echo "... <a href=\"modules.php?name=Shop&amp;go=action&amp;pagenum=$i\">$i</a>";
		}
		if (($i == 1) AND ($pagenum > 1+$pagelink)){
		echo "<a href=\"modules.php?name=Shop&amp;go=action&amp;pagenum=$i\">$i</a> ...";
		}
		}
	}
	if ($pagenum < $numpages) {
		$nextpage = $pagenum + 1 ;
		$rightarrow = "images/right.gif" ;
		echo "<a href=\"modules.php?name=Shop&amp;go=action&amp;pagenum=$nextpage\">";
		echo "<img src=\"$rightarrow\" align=\"absmiddle\" border=\"0\" hspace=\"10\"></a>";
	}
	echo "</div><br>" ;
     }
    footmenu();
    include("footer.php");
}

 switch($go) {

    case "search":
    search($query);
    break;

    case "cat":
    cat($cid);
    break;

    case "showcat":
    showcat($cid);
    break;

    case "goods":
    goods($pid);
    break;
    
    case "basket":
    basket($pid);
    break;
    
    case "order_check":
    order_check($order_name, $order_email, $order_tel, $order_tel2, $order_pid, $order_goods, $order_price, $order_text);
    break;
    
    case "count_change":
    count_change($id2, $gid, $count);
    break;
    
    case "clear_backen":
    clear_backen();
    break;
    
    case "order_goods":
    order_goods();
    break;
    
    case "order_send":
    order_send();
    break;
    
    case "order_history":
    order_history();
    break;

    case "action":
    action();
    break;
    
    default:
    main();
    break;

}


?>